package eventReservationServer.eventServerGateway;

import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;

import eventReservationServer.eventServerGateway.proxies.BarcelonaEventsWebServiceStub;

public class WSEventServerGateway implements IEventServerGateway //TODO
{
	public List<EventDO> getEvents()
	{
		List<EventDO> result = new ArrayList<EventDO>();
				
		BarcelonaEventsWebServiceStub stub = null;
		try
		{
			stub = new BarcelonaEventsWebServiceStub("http://localhost:8080/axis2/services/BarcelonaEventsWebService");
		}
		catch (Exception e) // quitamos AxisFault para que no falle ClassNotDefFound
		{
			e.printStackTrace();
		}
		eventReservationServer.eventServerGateway.proxies.BarcelonaEventsWebServiceStub.EventDTO[] eventsDTO = null;
		try
		{
			eventsDTO = stub.getEvents();
		}
		catch (RemoteException e)
		{
			e.printStackTrace();
		}
		
	
		for (eventReservationServer.eventServerGateway.proxies.BarcelonaEventsWebServiceStub.EventDTO eventDTO : eventsDTO)
		{
			result.add(new EventDO(0, eventDTO.getName(), eventDTO.getDate(), eventDTO.getDescription(), eventDTO.getPlaces()));
		}
		
		return result;
	}
}
